﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.InputDto;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Controllers
{
    /// <summary>
    /// 权限模块
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PermissionController : ControllerBase
    {
        IPermissionService service;


        public PermissionController(IPermissionService service)
        {
            this.service = service;
        }


        /// <summary>
        /// 查询角色菜单权限表 
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult  GetMenuRolePermissions()
        {
            var list= service.GetMenuRolePermissions();
            //  return Results<object>.DataResult(list);
            return Ok(list);
        }

        /// <summary>
        /// 查询显示权限表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public Results<List<Permission>> GetPermission()
        {
            var list = service.GetPermission();
            return Results<List<Permission>>.DataResult(list);
        }


        /// <summary>
        /// 批量添加角色菜单权限表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Results<int> AddMenuRolePermission(MenuRolePermissionInput input)
        {
            var list = service.AddMenuRolePermission(input);
            return Results< int>.DataResult(list);
        }
    }
}
